home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / LIB / PULLRIGH.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  4.5 KB  |  169 lines

  1. package sub_arctic.lib;
  2. import sub_arctic.input.*;
  3. import sub_arctic.output.*;
  4.  
  5. import java.awt.Point;
  6. import java.awt.Font;
  7.  
  8. /*
  9.  * This is a menu item which can pullright a submenu.  It is derived
  10.  * from a text menu item, so it shows a text label in its area.
  11.  *
  12.  * @author Ian Smith 
  13.  */
  14. public class pullright_menu_item extends text_menu_item {
  15.  
  16.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  17.  
  18.   /**
  19.    * Value of the menu we are displaying
  20.    */
  21.   protected menu _pullright;
  22.  
  23.   /**
  24.    * Return the value of the menu we are capable of pulling to the right.
  25.    * @return menu the menu object that we pull right
  26.    */
  27.   public menu pullright() { return _pullright;};
  28.  
  29.   /**
  30.    * Set the menu that we pull to the right.
  31.    * @param menu p the new pull right menu
  32.    */
  33.   public void set_pullright(menu p) { _pullright=p;};
  34.  
  35.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  36.  
  37.   /**
  38.    * Construct one of these pullright menu thingees.
  39.    *
  40.    * @param String t     the string to display.
  41.    * @param Font   f     the font to display the string in.
  42.    * @param int    width the width of the item.
  43.    * @param menu   m     the menu to pull right.
  44.    */
  45.   public pullright_menu_item(String t, Font f,
  46.                  int width, menu m) 
  47. {
  48.  
  49.     super(t,f,width);
  50.     _pullright=m;
  51.   }
  52.  
  53.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  54.  
  55.   /**
  56.    * Construct one of these pullright menus with a default font.
  57.    *
  58.    * @param String t     the string to display.
  59.    * @param int    width the width of the item.
  60.    * @param menu   m     the menu to pull right.
  61.    */
  62.   public pullright_menu_item(String t, int width, menu m) 
  63. {
  64.  
  65.     super(t,width);
  66.     _pullright=m;
  67.   }
  68.  
  69.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  70.  
  71.   /*
  72.    * Do the highlight behavior. This ends up popping up the menu.
  73.    * @param event e the event that caused the highlight.
  74.    */
  75.   public void highlight(event e) 
  76. {
  77.  
  78.     /* our upper left is the coordinate in question */
  79.     Point p=new Point(0,0);
  80.  
  81.     /* superclass behavior */
  82.     super.highlight(e);
  83.  
  84.     /* get the toplevel */
  85.     top_level tl=get_top_level();
  86.  
  87.     /* convert to global space */
  88.     p=local_to_global(p);
  89.  
  90.     /* now pop the menu up if we have one */
  91.     if (pullright()!=null) {
  92.  
  93.       /* set the location of the menu */
  94.       pullright().set_x(p.x+w());
  95.       pullright().set_y(p.y);
  96.  
  97.       /* put it in the list of children for our topmost parent */
  98.       tl.add_child(pullright());
  99.       menu.agent().add_to_focus(pullright(),e,null); /* no user info for now */
  100.     }
  101.   }
  102.  
  103.    //had:
  104.    //* @exception general PROPAGATED
  105.  
  106.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  107.  
  108.   /**
  109.    * Do the unhighlight behavior. This ends up popping down the menu.
  110.    * event e the event that caused the unhighlight
  111.    *
  112.    */
  113.   public void unhighlight(event e) 
  114. {
  115.  
  116.     /* do superclass behavior */
  117.     super.unhighlight(e);
  118.  
  119.     /* for cleanliness, we remove the child menu from its parent */
  120.     get_top_level().remove_child(pullright());
  121.   }
  122.  
  123.    //had:
  124.    //* @exception general PROPAGATED
  125.  
  126.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  127.  
  128.   /**
  129.    * Return a debugging string
  130.    * @return String the name of this class plus its location
  131.    */
  132.   public String toString() {
  133.     return "pullright_menu_item: [" + x() + "," + y() + "]";
  134.   }
  135.  
  136.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  137.  
  138.   /*
  139.    * Compute the new images for this object. We override this
  140.    * so we can get the little knicknack on the object for the
  141.    * pullright.
  142.    */
  143.   protected void style_changed() {
  144.     style cs=style_manager.current_style();
  145.  
  146.     _look=cs.menu_item_image(text(),font(),x_border(),y_border(),
  147.                 w(),h(),true);
  148.     damage_self();
  149.   }
  150.  
  151.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  152. }
  153. /*=========================== COPYRIGHT NOTICE ===========================
  154.  
  155. This file is part of the subArctic user interface toolkit.
  156.  
  157. Copyright (c) 1996 Scott Hudson and Ian Smith
  158. All rights reserved.
  159.  
  160. The subArctic system is freely available for most uses under the terms
  161. and conditions described in 
  162.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  163. and appearing in full in the lib/interactor.java source file.
  164.  
  165. The current release and additional information about this software can be 
  166. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  167.  
  168. ========================================================================*/
  169.